import request from '@/utils/request'

//登录接口
export function login(data) {
  return request({
    url: '/login',
    method: 'post',
    data
  })
}

//获取用户信息接口
export function getInfo() {
  return request({
    url: '/admin/user/getUserInfo',
    method: 'get',
  })
}


//退出登录接口
export function logout() {
  return request({
    url: '/logout',
    method: 'post'
  })
}


/**
 * 修改管理员密码
 * @param data 密码
 */
export function updateAdminPassword(data) {
  return request({
    url: "/admin/password",
    method: "put",
    data,
  });
}

//后台用户列表 /admin/user/list
export function getUserList(queryParams) {
  return request({
    url: '/admin/user/list',
    method: 'get',
    params: queryParams
  })
}

//修改用户信息 /admin/user/update
export function updateUser(data) {
  return request({
    url: '/admin/user/update',
    method: 'put',
    data
  })
}

//禁用用户
export function disableUser(disableDTO) {
  return request({
    url: '/admin/user/changeStatus',
    method: 'put',
    data:disableDTO
  })
}

//获取所有在线用户
export function getAllOnlineUser(params) {
  return request({
    url: '/admin/online/list',
    method: 'get',
    params
  })
}

//下线某个用户
export function offlineUser(userId) {
  return request({
    url: '/admin/online/kick/' + userId,
    method: 'delete',
  })
}